module MC.UI {
    export class TitleBar {
        public constructor() {

        }
        private title:string='';
        private html:JQuery=null;
        /**
         * 创建标题栏
         * */
        public create(title:string='',fubiaoti='',href=""){

            this.title=title;
            if(this.html){
                this.html.find('.spantitle').text(title);
                return;
            }
            let html=$(`<div class="TitleBar">
                <a class="backBtn"></a>
                <span class="spantitle"></span>
                <a class="fuanniu fubiaoti ui_btn"></a>
            </div><div class="TitleBarBu"></div>`);
            $('body').prepend(html);
         //   $('.H5body').prepend(html);
            html.find('.spantitle').text(title);
            html.find('.fubiaoti').text(fubiaoti);
            if(fubiaoti==''){
                html.find('.fubiaoti').hide();
            }
            html.find('.backBtn').on('click',()=>{
                if(href!==''){
                    window.open(href,"_self");
                }else{
                    MC.back();     
                }
               
            });
            html.find('.fuanniu').on('click',()=>{
                this.fubiaoti&&this.fubiaoti();
            });
            this.html=html;
        }
        public fubiaoti:Function=null;
 

    }
}